using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GPSMap.Test
{
    public partial class Form1 : Form
    {
        Pen m_chirclePen;
        List<CoordinateKeeper> m_Circles;

        public Form1()
        {
            InitializeComponent();
            m_chirclePen = new Pen(Brushes.Chocolate, 3.5F);
            m_Circles = new List<CoordinateKeeper>();
        }

        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            this.CreateGraphics().DrawEllipse(m_chirclePen, e.X - 10, e.Y - 10, 20, 20);
            CoordinateKeeper objCoord = new CoordinateKeeper();
            objCoord.CircleRegion = new Rectangle(e.X - 10, e.Y - 10, 20, 20);
            m_Circles.Add(objCoord);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < m_Circles.Count; )
            {
                m_Circles.RemoveAt(i);
            }
            //m_Circles.RemoveAt(m_Circles.Count - 1);
            this.Refresh();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = CreateGraphics();
            Pen p = new Pen(Color.Red);
            g.DrawRectangle(p, 20, 20, 40, 40);

            Graphics formGraf = this.CreateGraphics();
            foreach (CoordinateKeeper oneCircle in m_Circles)
            {
                formGraf.DrawEllipse(m_chirclePen, oneCircle.CircleRegion);
            }
        }

        

    }

    class CoordinateKeeper
    {
        public Rectangle CircleRegion;
    }
}